Vessel Updates Via JMS

To synchronize the vessel visit schedule from N4 with your external systems via JMS, you can call the following groovy code from the general notice pegged to the VV_UPDATE event which will be called for both the create and the update of a vessel visit.

println("BEGIN JMS Message" );

def list = ["VesselVisitId",

         "VesselRadioCallSign",

         "VesselId","VesselName",

         "LastBerthingQuayId", "LastBerthingQuayName",

         "VesselLineOperator","VesselLineOperatorName",

         "VesselClassLoaCm", "VesselClassGrossRegTon", "VesselClassNetRegTon",

         "IbVoyageNbr", "ObVoyageNbr",

         "TimeEstimatedArrival", "TimeEstimatedDeparture",

         "TimeActualArrival", "TimeActualDeparture",

         "VesselService","VesselServiceName",

         "TimeCargoCutoff", // dry cutoff

         "TimeStartWork", "TimeEndWork",

         "VisitPhase"]

def xml = event.getPropertyXml("vesselvisit", list);

println(xml);

api.sendXml(xml);

println("END JMS Test");

The getPropertyXml API

public String getPropertyXml(String inElementName, List<String> inReportingTags)

will construct xml list of attributes. Also api.sendJMSBytesMessage(xml) API should be used in lieu of a text message for .Net JMS clients using NMS.

The log output will look something like this which lists the sent JMS message

BEGIN JMS Message

<vesselvisit EVENT_ID="UPDATE_VV" EVENT_GKEY="323381" ENTITY_GKEY="13582"

VesselVisitId="PRV053A" VesselRadioCallSign="ELJP4"

VesselId="PRV" VesselName="PROVIDER" LastBerthingQuayId="C3" LastBerthingQuayName="??C3??"

VesselLineOperator="NYK" VesselLineOperatorName="Nippon Yusen Kaisha (NYK)"

VesselClassLoaCm="123456789" VesselClassGrossRegTon="33333.0" VesselClassNetRegTon="22222.0"

IbVoyageNbr="157" ObVoyageNbr="158"

TimeEstimatedArrival="2006-05-17 02:00" TimeEstimatedDeparture="2006-05-17 18:00"

TimeActualArrival="2006-08-25 04:48" TimeActualDeparture="" VesselService="NZAX"

VesselServiceName="NZAX" TimeCargoCutoff=""

TimeStartWork="2006-08-25 05:24" TimeEndWork=""

VisitPhase="40WORKING" />

END JMS Test

The vessel visit phase is returned as the database stored code instead of the description:

<codes entity="VesselVisitDetails" tag="VisitPhase">

<code dbvalue="10CREATED" desc="Created" />

<code dbvalue="20INBOUND" desc="Inbound" />

<code dbvalue="30ARRIVED" desc="Arrived" />

<code dbvalue="40WORKING" desc="Working" />

<code dbvalue="50COMPLETE" desc="Complete" />

<code dbvalue="60DEPARTED" desc="Departed" />

<code dbvalue="70CLOSED" desc="Closed" />

<code dbvalue="80CANCELED" desc="Canceled" />

<code dbvalue="90ARCHIVED" desc="Archived" />

</codes>

Note when you advance the phase visit of a vessel, both the VV_PHASE as well as the VV_UPDATE event will both be triggered. This will be desired behavior as you may have different notification behavior configured for both events.

No delete events will be sent since inside the notification cannot send an event on an object that no longer exists. You are recommended to purge both systems for inactive visits for an inactivce date horizon.

For on demand synchronization, SN4 provides Universal Query via SNX mode.